package cn.jrainbow.util;

import java.util.List;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;

/**
 * Extjs 生成Json数据
 * 
 * @author rainbow 
 */
public class ExtHelper {
	public static String getJsonFromList(Long total,List<?> data){
	    GridData grid = new GridData();
	    grid.setTotalCount(total);
	    grid.setData(data);

	    JSONObject jsonArray = JSONObject.fromObject(grid);
	    return jsonArray.toString();
	}
	
	public static String getJsonFromObject(Object data){
		FormData form = new FormData();
		form.setData(data);
		form.setSuccess(true);
		return JSONObject.fromObject(form).toString();
	}
}
